$(function() {
	//初始化datatable
	$("#table").XRDataTable({
		ajaxUrl: "Admin/Journal/getDatas",
		paramFunc: paramFunc,
		operation: {
			"edit": ["Admin/Journal/edit/#id","编辑"]
		},
		hasCheckbox: false,
		afterFunc:afterFunc
	});

	$('.cart-c-title-icon').click(function() {
        	$('.cart-c').animate({ right: "-400px" }, function() {
        });
    });
    resetCartPosition();
    $(window).resize(function(){
    	resetCartPosition();
    });
});

var paramFunc = function() {
	var data = getFormJson();
	return data;
};

var afterFunc = function(){
	// alert(JSON.stringify(trData));
	$("#table tbody tr").each(function() {
		var data = $("#table").getOpts().datas[$(this).index()];
		if(data.is_audit)
		{
			$(this).find('#icon-ok').show();
			$(this).find('#icon-trash').show();
		}
		else{
			$(this).find('#icon-ok').hide();
			$(this).find('#icon-trash').hide();
		}
		if(data.status==$("#unSubmit").val())
		{
			$(this).find('#icon-legal').hide();
		}
		if(data.change_status=='99'){
			$(this).addClass('tr-red');
		}else if(data.change_status=='3'){
			$(this).addClass('tr-green');
		}

	
	});
	//二维码放大
	imgBig('erweima img');
}

function resetCartPosition() {
    $('.cart-c').height(Number($(window).height()) - 55);
    $('.cart-c-box').height(Number($(window).height()) - 105);
}




var deleteModule=function(idx, trData){
	var msg = "是否确认删除【" + trData.name + "】?";
	swal({
		title: "请确认",
		text: msg,
		type: "warning",
		showCancelButton: true,
		closeOnConfirm: true,
		confirmButtonText: "确定",
		cancelButtonText: '取消',
		confirmButtonColor: "#ec6c62"
	}, function(isConfirm) {
		if(isConfirm) {
			$.ajax({
				type: "post",
				url: "Admin/Paper/delete/"+trData.id,
				async: true,
				success: function(data) {
					var ret = $.parseJSON(data);
					if(ret.status) {
						window.parent.topMessagePrompt('success',ret.msg);
	                    window.parent.refreshTable();
					} else {
						window.parent.topMessagePrompt('error',ret.msg);
					}
				}
			});
		}
	});
}


